package pl.com.ozzy.ozsign.ui;

import pl.com.ozzy.ozsign.tools.AppConfigManager;
import pl.com.ozzy.ozsign.tools.PreferencesWrapper;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;

public class WelcomeScreenUI extends Activity {
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcomescreenui);
        setResult(AppConfigManager.STATUS_OPTIONS_CANCELED);
        
        /*
         * All variables which we want to use in onClickListener have to 
         * be declared with the modifier final.
         */
        final PreferencesWrapper prefs = new PreferencesWrapper(this);
        /*
         * All setting should be reseted here. There is no reason
         * to restoring defaults before showing wizard.
         */
        prefs.resetToDefaults();
        
        final CheckBox cbSysIntegration	= (CheckBox)findViewById(R.id.cbSysIntegration);
        final CheckBox cbSignImages 		= (CheckBox)findViewById(R.id.cbSignImages);
        final CheckBox cbSignVideos 		= (CheckBox)findViewById(R.id.cbSignVideos);
        
        Button bSave	= (Button)findViewById(R.id.bSave);
        
        /*
         * We use anonymous class for onClickListener 
         */
        bSave.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				prefs.setBooleanValue(AppConfigManager.USE_MEDIA_SCANNER, cbSysIntegration.isChecked());
				prefs.setBooleanValue(AppConfigManager.SIGN_IMAGES, cbSignImages.isChecked());
				prefs.setBooleanValue(AppConfigManager.SIGN_VIDEOS, cbSignVideos.isChecked());
				prefs.setBooleanValue(AppConfigManager.RESET_SETTINGS, false);
				setResult(AppConfigManager.STATUS_OPTIONS_CLOSED);
				finish();
			}
		});
    }
}
